package com.teemor.tim.enums;

import com.teemor.tim.model.message.impl.CustomMessage;
import com.teemor.tim.model.message.impl.FaceMessage;
import com.teemor.tim.model.message.impl.FileMessage;
import com.teemor.tim.model.message.impl.ImageMessage;
import com.teemor.tim.model.message.impl.LocationMessage;
import com.teemor.tim.model.message.Message;
import com.teemor.tim.model.message.impl.SoundMessage;
import com.teemor.tim.model.message.impl.TextMessage;
import com.teemor.tim.model.message.impl.VideoFileMessage;

import java.util.Arrays;

/**
 * @ename zhoulk
 * @cname 周李科
 * @date 2020/12/16 14:34
 */
public enum MessageType {
    //文本消息
    TIMTextElem(TextMessage.class),
    //地理位置消息
    TIMLocationElem(LocationMessage.class),
    //表情消息
    TIMFaceElem(FaceMessage.class),
    //自定义消息
    TIMCustomElem(CustomMessage.class),
    //语音消息
    TIMSoundElem(SoundMessage.class),
    //图像消息
    TIMImageElem(ImageMessage.class),
    //文件消息
    TIMFileElem(FileMessage.class),
    //视频消息
    TIMVideoFileElem(VideoFileMessage.class);

    public Class<? extends Message> messageType;

    MessageType(Class<? extends Message> messageType) {
        this.messageType = messageType;
    }

    public static MessageType valOf(String type) {
       return Arrays.stream(values()).filter(messageType -> messageType.toString().equals(type)).findAny().orElse(null);
    }
}
